package com.olocat.cjx.nsims.pojo.entry

import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.olocat.cjx.nsims.pojo.info.OperationLog
import com.olocat.cjx.nsims.pojo.personnel.Nurse
import org.hibernate.annotations.GenericGenerator
import java.sql.Timestamp
import javax.persistence.*

@Entity
@Table(name = "entry_nurse")
@JsonIgnoreProperties(value = ["hibernateLazyInitializer", "handler"])
class EntryNurse {
    @Id
    @GeneratedValue(generator = "entry_nurse_generator")
    @GenericGenerator(name = "entry_nurse_generator", strategy = "uuid")
    var id: String? = null
    var name: String? = null
    var age: Int? = null
    var gender: Byte? = null

    @Column(name = "car_type")
    var carType: Byte? = null

    @Column(name = "car_id")
    var carId: String? = null
    var phone: String? = null
    var department: Int? = null
    var level: Byte? = null
    var school: String? = null
    var description: String? = null
    var avatar: String? = null
    var applicant: String? = null

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    var time: Timestamp? = null
    var progress: Int? = null
    var address: String? = null
    var experience: Byte? = null
    var certificate: String? = null
    var university: String? = null
    var major: String? = null
    var step: Int = 0
    var state: Byte? = null

    @OneToMany
    @JoinColumn(name = "person_id")
    var operationLog: List<OperationLog>? = null

    fun toNurse(): Nurse {
        return Nurse(this.name,this.age,this.gender,this.carType,this.carId,this.phone,this.department,this.level,this.school)
    }

    override fun toString(): String {
        return "EntryNurse{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", gender=" + gender +
                ", carType=" + carType +
                ", carId='" + carId + '\'' +
                ", phone='" + phone + '\'' +
                ", department=" + department +
                ", level=" + level +
                ", school='" + school + '\'' +
                ", description='" + description + '\'' +
                ", avatar='" + avatar + '\'' +
                ", applicant='" + applicant + '\'' +
                ", time=" + time +
                ", progress=" + progress +
                ", address='" + address + '\'' +
                ", experience=" + experience +
                ", certificate='" + certificate + '\'' +
                ", university='" + university + '\'' +
                ", major='" + major + '\'' +
                '}'
    }
}